GtkWidget: Construct style for partial widget hierarchies.
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 2 Aug 2010 14:11:40 +0000 (16:11 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Sat, 4 Dec 2010 14:37:25 +0000 (15:37 +0100)
Some unparented widgets like to ask style details, so now the style is
constructed regardless of the parent being present or not, and then
reconstructed if the parent changes.

gtk/gtkwidget.c

index 24cb3809237748fd929e9df99b2ebb75ab89b33e..8cca7a07dda7bb70d7b58c3991c0fb3cb98f4ca2 100644 (file)
@@ -13195,7 +13195,6 @@ gtk_widget_get_path (GtkWidget *widget)
   GList *regions, *reg;
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-  g_return_val_if_fail ((widget->parent || gtk_widget_is_toplevel (widget)), NULL);
 
   parent = widget->priv->parent;
 
@@ -13254,6 +13253,7 @@ gtk_widget_get_style_context (GtkWidget *widget)
   if (G_UNLIKELY (!context))
     {
       static GtkCssProvider *css_provider = NULL;
+      GtkWidgetPath *path;
 
       context = g_object_new (GTK_TYPE_STYLE_CONTEXT, NULL);
       g_object_set_qdata_full (G_OBJECT (widget),
@@ -13284,18 +13284,13 @@ gtk_widget_get_style_context (GtkWidget *widget)
                                       GTK_STYLE_PROVIDER (css_provider),
                                       GTK_STYLE_PROVIDER_PRIORITY_USER);
 
-      if (widget->parent ||
-          gtk_widget_is_toplevel (widget))
-        {
-          GtkWidgetPath *path;
 
-          path = gtk_widget_get_path (widget);
-          gtk_style_context_set_path (context, path);
-          gtk_widget_path_free (path);
+      path = gtk_widget_get_path (widget);
+      gtk_style_context_set_path (context, path);
+      gtk_widget_path_free (path);
 
-          gtk_style_context_set_screen (context,
-                                        gtk_widget_get_screen (widget));
-        }
+      gtk_style_context_set_screen (context,
+                                    gtk_widget_get_screen (widget));
     }
 
   return context;